// /common/http.api.js

// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)


// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// 此处没有使用传入的params参数
	let getCaptcha = () => vm.$u.get('/adminapi/captcha_pro');

	// 此处使用了传入的params参数，一切自定义即可
	let login = (params = {}) => vm.$u.post('/adminapi/login', params);

	let getStore = (params = {}) => vm.$u.get('/adminapi/merchant/store', params);
	let changeStore = (params = {}) => vm.$u.get('/adminapi/appointment/lst', params);
	//获取员工管理列表
	let getAdminList = (params = {}) => vm.$u.get('/adminapi/setting/admin', params);
	let editAdminList = (id, params) => vm.$u.put(`/adminapi/setting/admin/${id}`, params);
	let addAdminList = (params) => vm.$u.post(`/adminapi/setting/admin`, params);
	let deteleAdminList = (id) => vm.$u.delete(`/adminapi/setting/admin/${id}`);
	let getRoleList = (id) => vm.$u.get(`/adminapi/setting/role`);
	//获取当前登录人信息
	let getNowAdminInfo = (params = {}) => vm.$u.get(`/adminapi/setting/info`);
	let getCarList = (params = {}) => vm.$u.get(`/adminapi/car/Lst`);
	let getCarInfo = (params = {}) => vm.$u.get('/adminapi/car/info', params);
	let getCarDetail = (params = {}) => vm.$u.get(`/adminapi/car/detail`, params);
	let getAppointmentDetail = (params = {}) => vm.$u.get('/adminapi/appointment/detail', params);
	let getCategory = () => vm.$u.get('/api/category');
	//获取商品列表
	let getProducts = (id,uid) => vm.$u.get(`/api/products?sid=${id}`);
	let getAppEdit = (params={}) => vm.$u.get(`/adminapi/appointment/edit`,params);
	
	//预约购物车
	let cart_add = (params = {}) => vm.$u.post('/adminapi/appointment/cart_add', params);  
	let cart_num =  (params = {}) => vm.$u.post('/adminapi/appointment/cart_num', params); 
	let cart_del = (params = {}) => vm.$u.delete('/adminapi/appointment/cart_del',params);
	let cart_list =(params = {}) => vm.$u.get(`/adminapi/appointment/cart_list`,params);
	let submit =  (params = {}) => vm.$u.post('/adminapi/appointment/submit', params); 
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		getCaptcha,
		login,
		getStore,
		changeStore,
		getAdminList,
		getRoleList,
		editAdminList,
		addAdminList,
		deteleAdminList,
		getNowAdminInfo,
		getCarList,
		getCarInfo,
		getCarDetail,
		getAppointmentDetail,
		getCategory,
		getProducts,
		getAppEdit,
		cart_add,
		cart_num,
		cart_del,
		cart_list,
		submit
	};
}

export default {
	install
}
